﻿<#-- 
 
 crea una extension para la clase para c# para la tabla  ${table}...
 basicamente para su uso como objectDataSource ...
 Author : Luis Molina...
 
 -->
<#-- variables used internally by the generator... -->
<#assign nameFile="${table}">
<#assign extensionFile="cs">
<#assign languageGenerated="c#">
<#assign description="c#">
<#assign targetDirectory="">
<#assign appliesToAllTables="true">
<#-- END variables used internally by the generator... -->
 
 
 <asp:datagrid id="dg${table}" runat="server" BorderWidth="1px" BorderStyle="Solid" BorderColor="Transparent"
	CssClass="textoDetalle" AutoGenerateColumns="False" Width="100%" OnSelectedIndexChanged="dg${table}_SelectedIndexChanged"  OnItemCommand="dg${table}_ItemCommand">
	<AlternatingItemStyle BackColor="White"></AlternatingItemStyle>
	<ItemStyle BackColor="#DBE0C5"></ItemStyle>
	<HeaderStyle Font-Bold="True" ForeColor="Black" BackColor="#CFDE8A"></HeaderStyle>
	<FooterStyle BackColor="#CCCC99"></FooterStyle>
	<Columns>
		<#list table.getFields() as field>
			<asp:BoundColumn DataField="${field}" HeaderText="${field.getTargetName()}" >
				<HeaderStyle HorizontalAlign="Center" CssClass="textoDetalleNegrita"></HeaderStyle>
				<ItemStyle HorizontalAlign="Center"></ItemStyle>
			</asp:BoundColumn>  				 
		</#list>  
		<asp:TemplateColumn>
			<ItemStyle Width="20px"></ItemStyle>
			<ItemTemplate>
				<asp:imagebutton id="cmdSelect" runat="server" causesvalidation="false" CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.${table.getKey()}")%>'  ImageUrl="images/Reservar.gif" >
				</asp:imagebutton>
			</ItemTemplate>
		</asp:TemplateColumn>
	</Columns>
</asp:datagrid>
 

 
 
 
	// llamar a esta funcion en !page.ispostback
	
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			  dg${table}.DataSource = ${table}.getList();
              dg${table}.DataBind();

		}                	   
	}
		
		
	 protected void dg${table}_SelectedIndexChanged(object sender, EventArgs e)
	{
		// DetailsLabel.Text = "Item Number: " + dg${table}.SelectedItem.Cells[1].Text + "<br />";
	}
		
	

    public void dg${table}_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
		if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Pager)
		{
			if(e.CommandName == "Select")
			{
				//Response.Redirect("EditReorg.aspx?value=" + e.CommandArgument);
				//int Value1=sf.entero(e.CommandArgument);

			}
		}
    }


	
  
	 

 
 